package com.aps.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.aps.entity.ResultEntity;
import com.aps.entity.domain.schedule.PriorityRule;
import com.aps.service.rep.PriorityRuleRep;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author liaoguangan
 * @description <>
 * @date 2018/4/9 18:32
 */

@RestController
@RequestMapping("/manage-api")
@Api(value = "manage-priority-api", description = "优先级管理接口")
public class PriorityApi {

    @Autowired
    private PriorityRuleRep priorityRuleRep;

    @RequestMapping(value = "/priority", method = RequestMethod.GET)
    @ApiOperation("查询优先级列表")
    public ResultEntity listPri() {
        return new ResultEntity(priorityRuleRep.findAllByOrderByPriorityAsc());
    }

    @RequestMapping(value = "/priority", method = RequestMethod.POST)
    @ApiOperation("更新优先级")
    public ResultEntity updatePri(@RequestBody List<PriorityRule> rules) {
        return new ResultEntity(priorityRuleRep.save(rules));
    }
}
